<template>
  <div class="flex">
    <div class="normal-vuex">
      <div>
        <div class="w-100 ib">parent</div>
        <el-select v-model="pvalue" @change="getParent" placeholder="parent data">
          <el-option
            v-for="item in parentOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </div>
      <Daughter />
      <Son />
    </div>
    <mapModules />
  </div>

</template>
 
<script>
import Son from './son'
import Daughter from './daughter'
import mapModules from './modules/parent'
export default {
  name: '',
  components: { Daughter, Son, mapModules },
  data () {
    return {
      // parentOptions: [
      //   {value: '选项1', label: 'label1'},
      //   {value: '选项2', label: 'label2'},
      //   {value: '选项3', label: 'label3'}
      // ],
      // pvalue: '选项2'
    }
  },
  computed: {
    // 扩展mapState()
    parentOptions() {
      return this.$store.state.cellData.options
    },
    pvalue: {
      get() {
        return this.$store.state.cellData.value
      },
      set(v) {
        this.$store.state.cellData.value = v
      }
    }
  },
  mounted() {
    // console.log(this.$store)
  },
  methods: {
    getParent(v) {
      // console.log(v)
      // 扩展 mapActions()
      this.$store.dispatch('cellData/changeOption', v)
    }
  }
}
</script>
 
<style scoped lang="scss">
 
</style>